<template>
	<div>
		<el-row>
			<el-col class="num" :span="12">
				<span>
					<h2 style="font-size:25px ;">未发药患者</h2>
				</span>
				<el-divider style="width: 10;"></el-divider>
			</el-col>
			<el-col class="num" :span="12">
				<span>
					<h2>已发药患者</h2>
				</span>
				<el-divider></el-divider>
			</el-col>
		</el-row>
		<el-form :model="pdrug">
			<el-row>
				<el-col class="num" :span="5">
					<el-form-item prop="idnumber">
						<el-input v-model="pdrug.idnumber" placeholder="请输入患者就诊卡ID" style="width: 10;"></el-input>
					</el-form-item>
				</el-col>

				<el-col class="num" :span="4">
					<el-form-item>
						<el-button type="primary" @click="getidpdrug()">搜索</el-button>
						<el-button type="primary" @click="getallpdrug()">显示</el-button>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<el-row>
			<el-col :span="10">
				<el-table :data="notpdrug" max-height="800px" border style="width: 100%;background-color: #ddf3ff;">
					<el-table-column prop="idnumber" label="就诊卡ID" width="100">
					</el-table-column>
					<el-table-column prop="name" label="姓名" width="80">
					</el-table-column>
					<el-table-column prop="drug" label="药品" width="135">
					</el-table-column>
					<el-table-column prop="state" label="发药状态" width="100">
					</el-table-column>
					<el-table-column prop="" label="操作" width="96">
						<template slot-scope="scope">
							<el-button @click="update(scope.$index,notpdrug);getallpdrug()">发药</el-button>
						</template>
					</el-table-column>
				</el-table>
			</el-col>
			<el-col :span="2"></el-col>
			<el-col :span="12" offset="2">
				<el-table :data="alpdrug" max-height="800px" border style="width: 100%;background-color: #ddf3ff;">
					<el-table-column prop="idnumber" label="就诊卡ID" width="150">
					</el-table-column>
					<el-table-column prop="name" label="姓名" width="154">
					</el-table-column>
					<el-table-column prop="drug" label="药品" width="190">
					</el-table-column>
					<el-table-column prop="state" label="发药状态" width="120">
					</el-table-column>
				</el-table>
			</el-col>
		</el-row>
	</div>
</template>

<script>
	import {
		showMsgTitle
	} from '@/utils/api'
	import {
		showMsgConfirm
	} from '@/utils/api'
	import {
		getRequest
	} from '@/utils/api'
	import {
		postRequest
	} from '@/utils/api'
	import {
		uploadFileRequest
	} from '@/utils/api'
	import {
		putRequest
	} from '@/utils/api'
	import {
		deleteRequest
	} from '@/utils/api'
	import {
		showConstants
	} from '@/utils/api'
	import {
		mapMutations
	} from "vuex";
	export default {
		data() {
			return {
				pdrug: {
					name: ''
				},
				alpdrug: [],
				notpdrug: []
			}
		},
		methods: {
			getallpdrug() {
				this.$axios.get('http://localhost:8081/notpdrug').then((result) => {
					console.log(result.data);
					this.notpdrug = result.data
				}).catch((err) => {
					console.log(error);
				});
				this.$axios.get('http://localhost:8081/alpdrug').then((result) => {
					console.log(result.data);
					this.alpdrug = result.data
				}).catch((err) => {
					console.log(error);
				});
			},
			getidpdrug() {
				//postRequest('/idregister?idnumber='+this.formInline.idnumber);
				this.$axios.get('http://localhost:8081/idpdrug?idnumber=' + this.pdrug.idnumber).then((result) => {
					console.log(result.data);
					this.notpdrug = result.data
				}).catch((err) => {
					console.log(error);
				});


			},
			update(index, rows) {
				postRequest('/uppdrug?idnumber=' + this.notpdrug[index].idnumber).then(resp => {
					rows.splice(index, 1);
				})
			}


		}





	}
</script>



<style>
</style>
